package com.lovo.Game;

import javax.swing.*;

public class Game {
    private int score;
    People play1 = new People();
    Computer npc1 = new Computer();

    public void run() {
        System.out.println("欢迎来猜拳联盟，你10机会猜拳,0是出拳，1是出剪刀，2是出布");
        System.out.println("如果获胜将得到3分，平局获得1分，失败扣除4分");
        for (int i = 0; i < 10; i++) {
            play1.generateNumbers();
            System.out.println(play1);
            npc1.generateNumbers();
            System.out.println(npc1);
            int result = play1.getNumbers() + npc1.getNumbers();
            if (play1.getNumbers() == 0) {
                if (result == 0) {
                    score += 1;
                    System.out.println("平局获得1分 当前分数：" + score);
                } else if (result == 1) {
                    score += 3;
                    System.out.println("平局获得3分 当前分数：" + score);

                } else if (result == 2) {
                    score -= 4;
                    System.out.println("失败扣除4分 当前分数：" + score);
                }
            }
            if (play1.getNumbers() == 1) {
                if (result == 1) {
                    score -= 4;
                    System.out.println("失败扣除4分 当前分数：" + score);
                } else if (result == 2) {
                    score += 1;
                    System.out.println("平局获得1分 当前分数：" + score);

                } else if (result == 3) {
                    score += 3;
                    System.out.println("获胜获得3分 当前分数：" + score);
                }
            }
            if (play1.getNumbers() == 2) {
                if (result == 2) {
                    score += 3;
                    System.out.println("平局获得3分 当前分数：" + score);

                } else if (result == 3) {
                    score -= 4;
                    System.out.println("失败扣除4分 当前分数：" + score);

                } else if (result == 4) {
                    score += 0;
                    System.out.println("平局获得1分 当前分数：" + score);

                }
            }
        }
        if (score >0){
            System.out.println("victory");
        }else {
            System.out.println("defeated");
        }
    }

    public static void main(String[] args) {
        Game game = new Game();
        game.run();
    }
}
